package com.contain.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.cloud.client.loadbalancer.LoadBalancerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

import java.util.Collections;

/**
 * @Auther: tianchao
 * @Date: 2021/7/4 22:41
 * @Description:
 */
@SpringBootApplication
public class ContainSystemApplication {
    public static void main(String[] args) {
        SpringApplication.run(ContainSystemApplication.class,args);
    }

    @Autowired
    private LoadBalancerClient loadBalancerClient;
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate(){
        RestTemplate restTemplate = new RestTemplate();
//        restTemplate.setInterceptors(Collections.singletonList(
//                new LoadBalancerInterceptor(loadBalancerClient)
//        ));
        return restTemplate;
    }
}
